package com.mercury.elasticsearch.controller;

import com.mercury.elasticsearch.service.EsProductService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author mercury
 */
@RestController
public class EsProductController {

    @Resource
    private EsProductService esProductService;


    @GetMapping("/save")
    public void save() {
        esProductService.saveDocument();
    }


    @GetMapping("/remove/{id}")
    public void delete(@PathVariable("id") String id) {
        esProductService.removeDocument(id);
    }

    @GetMapping("/search")
    public void findByKeyWords(@RequestParam("keywords") String keywords) {
        esProductService.findByKeyWords(keywords);
    }


    @GetMapping("/searchByConditions")
    public void findByConditions(@RequestParam("keywords") String keywords) {
        esProductService.findByConditions(keywords);
    }

}
